#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
using namespace std;

vector<string> letterCombinations(string digits) {
    vector<string> str{""};
    str.reserve(150);
    unordered_map<char, string> hashtable{
        {'2', "abc"},
        { '3', "def" },
        { '4', "ghi" },
        { '5', "jkl" },
        { '6', "mno" },
        { '7', "pqrs" },
        { '8', "tuv" },
        { '9', "wxyz" },
    };
    if (digits.empty())
    {
        str.erase(str.begin());
        return str;
    }
    string tmp;
    for (char& i : digits)
    {
        int n = str.size();
        for (int j = 0; j < n; j++)
        {
            tmp = str[0];
            str.erase(str.begin());
            for (auto& e : hashtable.at(i))
            {
                str.push_back(tmp + e);
            }
        }
    }
    return str;
}

int main()
{
    string digits = "23";
    vector<string> v1 = letterCombinations(digits);

    return 0;
}
